<!DOCTYPE html>
<html lang="en" xmlns:th="http://www.thymeleaf.org">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <meta name="description" content="">
    <meta name="keys" content="">
    <meta name="author" content="">
    <base th:href="@{/}">
    <link rel="stylesheet" href="bootstrap/css/bootstrap.min.css">
    <link rel="stylesheet" href="css/font-awesome.min.css">
    <link rel="stylesheet" href="css/login.css">
    <script src="jquery/jquery-2.1.1.min.js"></script>
    <script src="bootstrap/js/bootstrap.min.js"></script>
    <script>
        function apply(){
            var data={
                "projectId":parseInt(document.getElementById("body_1").getAttribute("projectId")),
                    "fundNum":parseFloat($("#fundNum").val()),
                "fundRequestReason":$("#fundRequestReason").val(),
                "password":parseInt($("#psd").val())
            };
            $.ajax({
                url:"http://localhost:81/project/fund/request",
                type:"post",
                data:JSON.stringify(data),
                success:function(data){
                    alert("提交申请成功!");
                    window.location.replace("http://localhost:81/member/my/crowd");
                },
                error:function(e){
                    console.log(data);
                    console.log(JSON.stringify(data));
                    alert("提交申请失败!");
                    //window.location.replace("http://localhost:81/member/my/crowd");
                    //console.log($.parseJSON(data).toString());
                    //window.location.replace("http://localhost:81");
                },
                contentType: 'application/json'
            });
        }
    </script>

</head>
<body id="body_1" th:projectId="${projectId}">
<div th:replace="pagehead::pagehead"></div>

<div class="container">

    <form  class="form-signin" role="form">

        <h2 class="form-signin-heading"><i class="glyphicon glyphicon-log-in"></i>资金申请</h2>
        <div class="form-group has-success has-feedback">
            <input type="text" name="loginacct" class="form-control" id="fundNum" placeholder="请输入申请资金数（元）" autofocus>

        </div>
        <div class="form-group has-success has-feedback">
            <textarea type=text name="userpswd" class="form-control" id="fundRequestReason" placeholder="请输入申请理由"
                      style="margin-top:10px;height: 200px" ></textarea>

        </div>
        <div class="form-group has-success has-feedback">
            <input type="password" name="loginacct" class="form-control" id="psd" placeholder="请输入钱包密码" autofocus>
            <span class="glyphicon glyphicon-lock form-control-feedback"></span>
        </div>
        <div class="checkbox" style="text-align:right;"><a  href="http://localhost:81/">返回首页</a></div>
        <button type="button" class="btn btn-lg btn-success btn-block"  th:onclick="apply()" >提交申请</button>

    </form>
</div>

</body>

</html>